<?php

namespace Entity;

class AdminMenu extends \Home {

    private $menu = array(
        'Account' => array(
            'Name' => '账号管理',
            'List' => array(
                'AccountList' => array(
                    'Name' => '账号',
                    'Url' => '/Account/Lists',
                    //'Roles' => [Auth::ACCOUNT_ADD, Auth::ACCOUNT_SHOW],
                ),
            ),
        ),
        'Company' => array(
            'Name' => '公司管理',
            'List' => array(
                'Search' => array(
                    'Name' => '公司基本信息',
                    'Url' => '/Company/Search',
                ),
                'LevelLists' => array(
                    'Name' => '等级信息',
                    'Url' => '/Level/Lists',
                ),
                'CategoryLists' => array(
                    'Name' => '资质信息管理',
                    'Url' => '/Certificate/CategoryLists',
                ),
                'Contacts' => array(
                    'Name' => '联系人管理',
                    'Url' => '/Contacts/Lists',
                ),
                'TemporaryContacts' => array(
                    'Name' => '临时联系人',
                    'Url' => '/Contacts/TemporaryContacts',
                ),
                'MergeContacts' => array(
                    'Name' => '合并联系人',
                    'Url' => '/Contacts/MergeContacts',
                ),
            ),
        ),
        'User' =>array(
            'Name' => '用户管理',
            'List' => array(
                'User' => array(
                    'Name' => '用户详情',
                    'Url' => '/User/User',
                ),
                'Message' => array(
                    'Name' => '留言列表',
                    'Url' => '/User/Message',
                ),
                'Correction' => array(
                    'Name' => '用户纠错',
                    'Url' => '/User/Correction',
                ),
                'Integral' => array(
                    'Name' => '积分管理',
                    'Url' => '/User/Integral',
                ),
            ),
        ),
        'Article' =>array(
            'Name' => '文章管理',
            'List' => array(
                'Add' => array(
                    'Name' => '添加文章',
                    'Url' => '/Article/Add',
                ),
                'Lists' => array(
                    'Name' => '文章列表',
                    'Url' => '/Article/Lists',
                ),
            ),
        ),
        'Integral' => array(
            'Name' => '积分系统',
            'List' => array(
                'Rule' => array(
                    'Name' => '积分规则',
                    'Url' => '/Integral/Rule',
                ),
            ),
        ),
        'Tools' => array(
            'Name' => '系统工具',
            'List' => array(
                'ParseId' => array(
                    'Name' => 'ID转换工具',
                    'Url' => '/Tools/ParseId',
                ),
                'CacheSet' => array(
                    'Name' => '缓存设置',
                    'Url' => '/Tools/CacheSet',
                ),
            ),
        ),
//        'Weixin' => array(
//            'Name' => '微信管理',
//            'List' => array(
//                'AutoResponse' => array(
//                    'Name' => '自动回复',
//                    'Url' => '/Weixin/AutoResponse',
//                ),
//                'CustomizeMenus' => array(
//                    'Name' => '自定义菜单',
//                    'Url' => '/Weixin/CustomizeMenus',
//                ),
//            ),
//        ),
        'Version' => array(
            'Name' => '版本管理',
            'List' => array(
                'Lists' => array(
                    'Name' => '版本详情',
                    'Url' => '/Version/Version',
                ),
            ),
        ),
        'UpdateCompany' => array(
            'Name' => '数据更新',
            'List' => array(
                'Del' => array(
                    'Name' => '删除的公司',
                    'Url' => '/UpdateCompany/Del',
                ),
                'Branch' => array(
                    'Name' => '分支机构变更',
                    'Url' => '/UpdateCompany/Branch',
                ),
                'EmptyAll' => array(
                    'Name' => '清空更新数据',
                    'Url' => '/UpdateCompany/EmptyAll',
                ),
            ),
        ),
        'Statistics' => array(
            'Name' => '访问量统计',
            'List' => array(
                'Lists' => array(
                    'Name' => '统计',
                    'Url' => '/Statistics/Lists',
                ),
                'RegionalMap' => array(
                    'Name' => '区域分布',
                    'Url' => '/Statistics/RegionalMap',
                ),
            ),
        ),
        'TenderNotice' => array(
            'Name' => '招标公告',
            'List' => array(
                'Thesaurus' => array(
                    'Name' => '关键词库',
                    'Url' => '/TenderNotice/Thesaurus',
                ),
                'Lists' => array(
                    'Name' => '公告列表',
                    'Url' => '/TenderNotice/Lists',
                ),
            ),
        ),
    );

    public function getMenuList() {
        $menu = $this->menu;
        foreach ($menu as  &$val) {
            $val['Roles'] = array();
            foreach ($val['List'] as $v) {
                if (!empty($v['Roles'])) {
                    $roles = is_array($v['Roles']) ? $v['Roles'] : array($v['Roles']);
                    foreach ($roles as $r) {
                        if (!in_array($r, $val['Roles'])) {
                            $val['Roles'][] = $r;
                        }
                    }
                }
            }
        }
        return $menu;
    }
}